package com.jiazhong.servlets;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * @Auther:shuXin
 */
/*
创建Servlet的这个实体类，这个类要实现servlet的接口(但是实现的方法比较多，所以我们继承一盒HttpServlet类)
 */
@WebServlet("/servletTest10")
public class ServletTest10 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        StringBuffer requestURL = req.getRequestURL();
        System.out.println("客户端请求的URL" + requestURL);

        String requestURI = req.getRequestURI();
        System.out.println("请求项目中具体资源" + requestURI);

        int serverPort = req.getServerPort();
        System.out.println("客户端发送请求的端口" + serverPort);

        int localPort = req.getLocalPort();
        System.out.println("本应用的容器的端口" + localPort);

        int remotePort = req.getRemotePort();
        System.out.println("客户端程序的端口" + remotePort);

        String scheme = req.getScheme();
        System.out.println("请求的协议" + scheme);

        String protocol = req.getProtocol();
        System.out.println("请求的协议以及版本号" + protocol);

        String method = req.getMethod();
        System.out.println("请求的方法" + method);

        String header = req.getHeader("GET /servlet_test_war/servletTest10 HTTP/1.1");
        System.out.println("请求头" + header);



    }
}
